<?php
/**
 * View do formulário de cliente
 * @filesource  06/04/2011
 * @author      Estrada Virtual <http://estradavirtual.com.br>
 * @copyright   Copyright <2011> Estrada Virtual
 * @package     <<application>>
 * @subpackage  <<application>>.application.views
 * @version     $Id$
 */
 ?>
<div class="ev-formulario">
    <div class="tit-page">
        <h2><?php echo $this->translate('id_cliente'); ?></h2>
    </div>

    <form action="<?php echo $this->baseUrl() ?>/corporativo/cliente/gravar" method="post" name="formulario" id="formulario">
        <fieldset>
        <input type="hidden" name="id_cliente" id="id_cliente" value="<?php echo $this->row->id_cliente; ?>" />

        <div class="campo">
            <label for="st_nome"><?php echo $this->translate('st_nome'); ?>&nbsp;<span class="campoObrigatorio">*</span>: </label>
            <input class="text ui-widget-content ui-corner-all required" type="text" name="st_nome" id="st_nome" value="<?php echo $this->row->st_nome; ?>" title="<?php echo $this->translate("st_nome"); ?>"  maxlength="200" /><br />
        </div>

        <div class="campo">
            <label for="st_CPF"><?php echo $this->translate('st_CPF'); ?>: </label>
            <input class="text ui-widget-content ui-corner-all cpf" type="text" name="st_CPF" id="st_CPF" value="<?php echo $this->row->st_CPF; ?>" title="<?php echo $this->translate("st_CPF"); ?>"  maxlength="14" /><br />
        </div>

        <div class="campo">
            <label for="st_CNPJ"><?php echo $this->translate('st_CNPJ'); ?>: </label>
            <input class="text ui-widget-content ui-corner-all cnpj" type="text" name="st_CNPJ" id="st_CNPJ" value="<?php echo $this->row->st_CNPJ; ?>" title="<?php echo $this->translate("st_CNPJ"); ?>"  maxlength="20" /><br />
        </div>

        <div class="campo">
            <label for="st_CF_DF"><?php echo $this->translate('st_CF_DF'); ?>: </label>
            <input class="text ui-widget-content ui-corner-all" type="text" name="st_CF_DF" id="st_CF_DF" value="<?php echo $this->row->st_CF_DF; ?>" title="<?php echo $this->translate("st_CF_DF"); ?>"  maxlength="45" /><br />
        </div>
        <fieldset>
            <legend>Endereço</legend>
            <div class="campo">
                <label for="st_CEP"><?php echo $this->translate('st_CEP'); ?>: </label>
                <input class="text ui-widget-content ui-corner-all cep" type="text" name="st_CEP" id="st_CEP" value="<?php echo $this->row->st_CEP; ?>" title="<?php echo $this->translate("st_CEP"); ?>"  maxlength="45" /><br />
            </div>

            <div class="campo">
                <label for="st_UF"><?php echo $this->translate('UF'); ?>: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_UF" id="st_UF" value="<?php echo $this->row->st_UF; ?>" title="<?php echo $this->translate("UF"); ?>" maxlength="2" size="2" /><br />
            </div>

            <div class="campo">
                <label for="st_cidade">Cidade: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_cidade" id="st_cidade" value="<?php echo $this->row->st_cidade; ?>" title="<?php echo $this->translate("st_cidade"); ?>"  maxlength="150" /><br />
            </div>

            <div class="campo">
                <label for="st_bairro">Bairro: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_bairro" id="st_bairro" value="<?php echo $this->row->st_bairro; ?>" title="<?php echo $this->translate("st_bairro"); ?>"  maxlength="150" /><br />
            </div>

            <div class="campo">
                <label for="st_logradouro">Logradouro: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_logradouro" id="st_logradouro" value="<?php echo $this->row->st_logradouro; ?>" title="<?php echo $this->translate("st_logradouro"); ?>"  maxlength="150" /><br />
            </div>

            <div class="campo">
                <label for="st_end_numero">Número: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_end_numero" id="st_complemento" value="<?php echo $this->row->st_end_numero; ?>" title="<?php echo $this->translate("st_end_numero"); ?>"  maxlength="5" /><br />
            </div>

            <div class="campo">
                <label for="st_end_complemento">Complemento: </label>
                <input class="text ui-widget-content ui-corner-all" type="text" name="st_end_complemento" id="st_complemento" value="<?php echo $this->row->st_end_complemento; ?>" title="<?php echo $this->translate("st_end_complemento"); ?>"  maxlength="255" /><br />
            </div>
        </fieldset>

        <div class="campo">
            <label for="st_telefone"><?php echo $this->translate('st_telefone'); ?>: </label>
            <input class="text ui-widget-content ui-corner-all telefone" type="text" name="st_telefone" id="st_telefone" value="<?php echo $this->row->st_telefone; ?>" title="<?php echo $this->translate("st_telefone"); ?>"  maxlength="45" /><br />
        </div>

    </fieldset>

        <div id="botoesAcao">
            <button type="submit" class="btSalvar" name="enviar" id="enviar">Enviar</button>
            <button class="btExcluir" name="cancelar" id="cancelar">Cancelar</button>
        </div>
    </form>
</div>
<script type="text/javascript">
    $().ready(function() {
        $("form").validate({
            ignoreTitle: true
        });

        $cep = $("#st_CEP");
        $cep.change(function() {
            url = "<?php echo $this->baseUrl(); ?>/corporativo/apoio/cep/cep/" + $cep.val();
            $.getJSON(url, function(data) {
                  if (data.status) {
                      $("#st_UF").val(data.uf);
                      $("#st_cidade").val(data.cidade);
                      $("#st_bairro").val(data.bairro);
                      $("#st_tipo_logradouro").val(data.tipologradouro);
                      $("#st_logradouro").val(data.logradouro);
                  }
            });
        });

        $('#cancelar').click(function(){
            window.location = "<?php echo $this->baseUrl() ?>/corporativo/cliente/visualizar/id/<?php echo $this->row->id_cliente; ?>";
        });
    });
</script>